Repository navigation
Fix Flow types that use void for a missing value (#2265) - #2265
Conversation
|
@SamChou19815 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D133660807. |
Metro review: Looks goodRisk: low · Commit: This PR changes two Flow libdef annotations from No findings. Verified
Not run: I ran no tests or benchmarks. The change touches only Flow libdef annotations, which have no runtime effect or performance cost. I didn't check behavior under Flow's Automated review by Claude. Advisory only: it never approves or blocks, and a maintainer makes the call. |
christophpurrer
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary: X-link: react/react-native#60206 Under Flow's `experimental.ts_void`, `void` is TypeScript's `void`, which flows only into `void`, `any` and `unknown`, so a value typed `void` can't be passed where an optional value or `undefined` is expected. This updates React Native's Flow types for projects that check React Native's sources with that option: - Library definitions say `undefined` where the TypeScript definitions do: `babel/traverse`'s `Scope#getBinding()`, `Scope#getOwnBinding()`, `Scope#getBindingIdentifier()` and `Scope#getOwnBindingIdentifier()`, and `child_process.spawnSync()`'s `error`. execa's `env` is read-only, so it accepts both `process.env` and objects with `void` values. - `BackHandler` handlers and the RN tester's stall handler may return nothing. - `EventTarget`'s listener maps and codegen's `bubblingType` use maybe types instead of `void`, `componentDidMount()` in `TouchableNativeFeedback` returns `void`, and two RN tester components that render nothing return `undefined`. - Where the only fix needs the `undefined` type, which this repository's Flow config doesn't enable, the error is suppressed. Without that option, `void` and `undefined` are the same type, so nothing changes. Changelog: [General][Changed] - Allow `BackHandler` event listeners to return nothing [General][Changed] - Type `TouchableNativeFeedback`'s `componentDidMount()` as returning `void` Reviewed By: christophpurrer Differential Revision: D133660807
void for a missing valuevoid for a missing value (#2265)
575d1d5 to
6097276
Compare
Summary: X-link: react/metro#2265 Under Flow's `experimental.ts_void`, `void` is TypeScript's `void`, which flows only into `void`, `any` and `unknown`, so a value typed `void` can't be passed where an optional value or `undefined` is expected. This updates React Native's Flow types for projects that check React Native's sources with that option: - Library definitions say `undefined` where the TypeScript definitions do: `babel/traverse`'s `Scope#getBinding()`, `Scope#getOwnBinding()`, `Scope#getBindingIdentifier()` and `Scope#getOwnBindingIdentifier()`, and `child_process.spawnSync()`'s `error`. execa's `env` is read-only, so it accepts both `process.env` and objects with `void` values. - `BackHandler` handlers and the RN tester's stall handler may return nothing. - `EventTarget`'s listener maps and codegen's `bubblingType` use maybe types instead of `void`, `componentDidMount()` in `TouchableNativeFeedback` returns `void`, and two RN tester components that render nothing return `undefined`. - Where the only fix needs the `undefined` type, which this repository's Flow config doesn't enable, the error is suppressed. Without that option, `void` and `undefined` are the same type, so nothing changes. Changelog: [General][Changed] - Allow `BackHandler` event listeners to return nothing [General][Changed] - Type `TouchableNativeFeedback`'s `componentDidMount()` as returning `void` Reviewed By: christophpurrer Differential Revision: D133660807
Summary: X-link: react/metro#2265 Under Flow's `experimental.ts_void`, `void` is TypeScript's `void`, which flows only into `void`, `any` and `unknown`, so a value typed `void` can't be passed where an optional value or `undefined` is expected. This updates React Native's Flow types for projects that check React Native's sources with that option: - Library definitions say `undefined` where the TypeScript definitions do: `babel/traverse`'s `Scope#getBinding()`, `Scope#getOwnBinding()`, `Scope#getBindingIdentifier()` and `Scope#getOwnBindingIdentifier()`, and `child_process.spawnSync()`'s `error`. execa's `env` is read-only, so it accepts both `process.env` and objects with `void` values. - `BackHandler` handlers and the RN tester's stall handler may return nothing. - `EventTarget`'s listener maps and codegen's `bubblingType` use maybe types instead of `void`, `componentDidMount()` in `TouchableNativeFeedback` returns `void`, and two RN tester components that render nothing return `undefined`. - Where the only fix needs the `undefined` type, which this repository's Flow config doesn't enable, the error is suppressed. Without that option, `void` and `undefined` are the same type, so nothing changes. Changelog: [General][Changed] - Allow `BackHandler` event listeners to return nothing [General][Changed] - Type `TouchableNativeFeedback`'s `componentDidMount()` as returning `void` Reviewed By: christophpurrer Differential Revision: D133660807 Pull Request resolved: #60206
Summary:
X-link: react/react-native#60206
Under Flow's
experimental.ts_void,voidis TypeScript'svoid, which flows only intovoid,anyandunknown, so a value typedvoidcan't be passed where an optional value orundefinedis expected. This updates React Native's Flow types for projects that check React Native's sources with that option:undefinedwhere the TypeScript definitions do:babel/traverse'sScope#getBinding(),Scope#getOwnBinding(),Scope#getBindingIdentifier()andScope#getOwnBindingIdentifier(), andchild_process.spawnSync()'serror. execa'senvis read-only, so it accepts bothprocess.envand objects withvoidvalues.BackHandlerhandlers and the RN tester's stall handler may return nothing.EventTarget's listener maps and codegen'sbubblingTypeuse maybe types instead ofvoid,componentDidMount()inTouchableNativeFeedbackreturnsvoid, and two RN tester components that render nothing returnundefined.undefinedtype, which this repository's Flow config doesn't enable, the error is suppressed.Without that option,
voidandundefinedare the same type, so nothing changes.Changelog:
[General][Changed] - Allow
BackHandlerevent listeners to return nothing[General][Changed] - Type
TouchableNativeFeedback'scomponentDidMount()as returningvoidReviewed By: christophpurrer
Differential Revision: D133660807